<?php
class WorkerModel extends Model{
	protected $table='dw_workers';
	protected $pk='id';
	//表中的字段
	protected $fields=array('id','name','status','post','depart','mobile_no',
		'add_time');
	//自动验证规则
	protected $rules=array(
			
			array('post',1,'岗位不能为空','require'),
			array('depart',1,'部门不能为空','require')
			
			
		);
	//自动填充规则
	protected $leftfields=array(
		    array('status','value','1'),
			array('add_time','function','time')
		);

	
	protected function encPasswd($passwd){
		return md5($passwd);
	}


	public function findWorkersByDepart($depart){
    $sql="SELECT id,name,status,post, depart,mobile_no FROM ".$this->table." WHERE depart=".$depart;
    return $this->db->getAll($sql);
   }

    public function findAllWorkers(){
    $sql="SELECT * FROM ".$this->table;
    return $this->db->getAll($sql);
   }
   public function findWorkerByName($name){
    $sql='SELECT * FROM '.$this->table.' where name='.'"'.$name.'"';
    return $this->db->getAll($sql);
   }
   public function findWorkerByDepart($where){
    $sql='SELECT * FROM '.$this->table.' where depart='.'"'.$where.'"';
    return $this->db->getAll($sql);
}
public function findChecker($where){
    $sql='SELECT name FROM '.$this->table.' where post=4 and depart='.'"'.$where.'"';
    return $this->db->getAll($sql);
}

}
?>

